function AdminController(
    Meta,
    $http,
    API,
    store,
    $state,
    $scope,
    $rootScope,
    User
) {
    var admin = this
    // 把 API 暴露出来
    admin.api = API
    $rootScope.api = API


    admin.meta = Meta

    // 获取登录和当前管理员信息
    admin.loginInfo    = store.get('loginInfo')
    //
    admin.currentAdmin =new User(store.get('currentAdmin'))

    // 管理员头像下方快捷菜单
    admin.adminMenu = [
        {
        'text': '退出登录',
        'click': 'admin.signout()',
        'prefix': 'fa-power-off'
    }]
    // 退出登录
    admin.signout = function signOut() {
        $http.get(API + '/logoutCas')
        store.remove('loginInfo')
        store.remove('currentAdmin')
        $state.go('session.signin')
    }


    // var menus = [
    //     {"id":16,"name":"播放计划","hyperlink":"#","type":0,"position":1,"createDate":1479089830000,"permission":"w_general","oldlink":null,"icon":"icon-bar-chart"},
    //     {"id":2,"name":"机器人分组","hyperlink":"#","type":0,"position":2,"createDate":1435129690000,"permission":"w_top1","oldlink":"#","icon":"icon-graph"},
    //     {"id":1,"name":"机器人","hyperlink":"#","type":0,"position":3,"createDate":1435129664000,"permission":"w_top2","oldlink":"#","icon":"icon-users"}]

    var menus = [
        {"id":16,"name":"播放计划","hyperlink":"playplan","type":0,"position":1,"createDate":1479089830000,"permission":"playplan","oldlink":"#","icon":"null"},
        {"id":5,"name":"机器人分组","hyperlink":"groupList","type":0,"position":2,"createDate":1476240186000,"permission":"groupList","oldlink":"#","icon":null},
        {"id":6,"name":"机器人列表","hyperlink":"robotList","type":0,"position":3,"createDate":1476240657000,"permission":"robotList","oldlink":"#","icon":null},
        {"id":9,"name":"用户管理","hyperlink":"userList","type":0,"position":4,"createDate":1476244106000,"permission":"userList","oldlink":"#","icon":null},
        /*{"id":10,"name":"播放列表","hyperlink":"playplan","type":3,"position":2,"createDate":1476244106000,"permission":"playplan","oldlink":"#","icon":null},*/
    ];
    admin.permissions = [];
    if(admin.loginInfo.trueNameCheck=="NORMAL"){
        menus.splice(3)
    }
   admin.permissions = menus

    // 主菜单项目列表
    var _groups = _.groupBy(admin.permissions, 'type')

    admin.menus =  _.forEach(_groups[0], function(group) {
        console.info(group);
        group.items = [];
        _.forEach(_groups[group.position],function(item){
            console.info(item);
            alert("11111111111111111111");
            group.items.push(item);
        })
    })
    admin.menus=_.filter(admin.menus, function(o) { return o.items.length>=1|| !_.isEqual(o.hyperlink,'#'); });

    // User.permissions().$promise.then(function(response){
    //     // admin.permissions=response
    //     admin.permissions = menus
    //
    //     // 主菜单项目列表
    //     var _groups = _.groupBy(admin.permissions, 'type')
    //
    //     admin.menus =  _.forEach(_groups[0], function(group) {
    //         group.items = [];
    //
    //         _.forEach(_groups[group.position],function(item){
    //             console.info(item);
    //             group.items.push(item);
    //             // for(var i = 0;i < admin.currentAdmin.roleList.length;i++){
    //             //     var role = admin.currentAdmin.roleList[i];
    //             //     if(role.permissions.indexOf(item.permission + ':view') != -1
    //             //         || role.permissions.indexOf(item.permission + ':edit') != -1){
    //             //         group.items.push(item);
    //             //         break;
    //             //     }
    //             // }
    //         })
    //     })
    //     admin.menus=_.filter(admin.menus, function(o) { return o.items.length>=1|| !_.isEqual(o.hyperlink,'#'); });
    // })


    // 跟踪当前处于 active 的菜单项
    admin.activeMenu = -1

    // 判断目标菜单项是否为当前激活
    admin.isActiveMenu = function isActiveMenu(index) {
        alert(index);
        return (admin.activeMenu === index)
    }

    // 设置目标菜单项成为当前激活项
    admin.setActiveMenu = function setActiveMenu(index) {
        if (_.isUndefined(index)) {
            admin.activeMenu = -1
        } else {
            admin.activeMenu = (admin.activeMenu === index) ? -1 : index
        }
    }

}
